package com.cmy.framework_network.apiresponse

import com.cmy.framework_network.error.FailureHandler
import retrofit2.Call
import retrofit2.CallAdapter
import java.lang.reflect.Type

class NetworkResponseAdapter<S : Any> (
    private val delegate: Type,
    private val errorBodyConverter: FailureHandler?) :
    CallAdapter<S, Call<NetworkResponse<S>>> {
    override fun responseType(): Type = delegate

    override fun adapt(call: Call<S>): Call<NetworkResponse<S>> {
        return NetworkResponseCall(call, errorBodyConverter)
    }
}